<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="main">main</div>
    <script>
        /**
         * setAttribute('attributeName', 'attributeValue')
         * 如果attributeName已存在则其值会被替代
        */

        const div_main = document.getElementById('main')
        div_main.setAttribute('class', 'name')
        div_main.style="color:red" // 在dom对象上添加

        // removeAttribute('attributName')
        // 移除属性
        div_main.removeAttribute('class')
    </script>
</body>
</html>